<?PHP


// -------------------------------------------------------------------------------------------------------
function ShowTableDialog ($objname, $window) {
        echo "<html style='width: 390px; height: 170px; '>";
        echo "<head><title>"._TABLEDLGTITLE."</title><head>";
        echo "<style>html, body, button, div, input, select, td, fieldset { font-family: MS Shell Dlg; font-size: 8pt; };</style>";
        echo "<script>\n";
        echo "opener = window.dialogArguments;\n";
        echo "var _editor_url = opener._editor_url;\n";
        echo "objname         = location.search.substring(1,location.search.length);\n";
        echo "var config      = opener.document.all[\"". $objname ."\"].config;\n";
        echo "var editor_obj  = opener.document.all[\"_\" + \"". $objname ."\" + \"_editor\"];\n";
        echo "var editdoc     = editor_obj.contentWindow.document;\n";
        echo "function _CloseOnEsc() {\n";
        echo "if (event.keyCode == 27) { window.close(); return; }\n";
        echo "}\n";
        echo "window.onerror = HandleError\n";
        echo "function HandleError(message, url, line) {\n";
        echo "        str = \""._TABLEERRINTRO."\" + \"\\n\\n\"\n";
        echo "        + \""._TABLEERRERRDS."\" + line + \"\\n\" + message;\n";
        echo "        alert(str);\n";
        echo "        return true;";
        echo "}\n";
        echo "function Init() {\n";
        echo "        document.body.onkeypress = _CloseOnEsc;\n";
        echo "}\n";
        echo "function _isValidNumber(txtBox) {\n";
        echo "        var val = parseInt(txtBox);\n";
        echo "        if (isNaN(val) || val < 0 || val > 9999) { return false; }\n";
        echo "        return true;\n";
        echo "}\n";
        echo "function btnOKClick() {\n";
        echo "        curRange = editdoc.selection.createRange();\n";
        // error checking
        echo "        var checkList = ['rows','cols','border','cellspacing','cellpadding'];\n";
        echo "        for (var idx in checkList) {\n";
        echo "                var fieldname = checkList[idx];\n";
        echo "                if (document.all[fieldname].value == \"\") {\n";
        echo "                        alert(\""._TABLEWARNYOUM."'\" + fieldname + \"'"._TABLEWARNFIELD."\");\n";
        echo "                        document.all[fieldname].focus();\n";
        echo "                        return;\n";
        echo "                }\n";
        echo "                else if (!_isValidNumber(document.all[fieldname].value)) {\n";
        echo "                        alert(\""._TABLEWARNBADV1."'\" +fieldname+ \"'!\");\n";
        echo "                        document.all[fieldname].focus();\n";
        echo "                        return;\n";
        echo "                }\n";
        echo "        }\n";
        // delete selected content (if applicable)
        echo "        if (editdoc.selection.type == \"Control\" || curRange.htmlText) {\n";
        echo "                if (!confirm(\""._TABLEWARNOWERW."\")) { return; }\n";
        echo "                curRange.execCommand('Delete');\n";
        echo "                curRange = editdoc.selection.createRange();\n";
        echo "        }\n";
        // create table
        echo "        var table = '<table border=\"' +document.all.border.value+ '\"'\n";
        echo "        + ' cellspacing=\"' +document.all.cellspacing.value+ '\"'\n";
        echo "        + ' cellpadding=\"' +document.all.cellpadding.value+ '\"'\n";
        echo "        + ' width=\"' +document.all.width.value + document.all.widthExt.value+ '\"'\n";
        echo "        + ' align=\"' +document.all.alignment.value+ '\">\\n';\n";
        echo "        for (var x = 0; x < document.all.rows.value; x++) { \n";
        echo "                table += \" <tr>\\n\";\n";
        echo "                for (var y = 0; y < document.all.cols.value; y++) { \n";
        echo "                        table += \"  <td></td>\\n\";\n";
        echo "                }\n";
        echo "                table += \" </tr>\\n\";\n";
        echo "        }\n";
        echo "        table += \"</table>\\n\";\n";
        // insert table
        echo "        opener.editor_insertHTML(\"". $objname ."\", table);\n";
        // close popup window
        echo "        window.close();\n";
        echo "}\n";
        echo "</script>";
        echo "</head>";
        echo "<body id=bdy onload='Init()' style='background: threedface; color: windowtext; margin: 10px; BORDER-STYLE: none' scroll=no>";
        echo "<table border=0 cellspacing=0 cellpadding=0 style='margin: 0 0 8 0'>";
        echo "<tr>";
        echo         "<td>"._TABLEDLGROWS."</td>";
        echo         "<td><input type=text name=rows value=4 style='width: 50px' maxlength=4></td>";
        echo "</tr><tr>";
        echo         "<td>"._TABLEDLGCOLS."</td>";
        echo         "<td><input type=text name=cols value=3 style='width: 50px' maxlength=4></td>";
        echo         "<td width=10>&nbsp;</td>";
        echo         "<td>"._TABLEDLGWIDTH."</td>";
        echo         "<td><input type=text name=width value=100 style='width: 50px' maxlength=4>";
        echo                 "<select name=widthExt>";
        echo                 "<option value=\"\">"._TABLEDLGPIXEL."</option>";
        echo                 "<option value=\"%\" selected>"._TABLEDLGPERCENT."</option>";
        echo                 "</select>";
        echo         "</td>";
        echo "</tr>";
        echo "</table>";

        echo "<fieldset style='width: 1%; text-align: center'>";
        echo "<legend>"._TABLEDLGLAYOUT."</legend>";
        echo "<table border=0 cellspacing=6 cellpadding=0>";
        echo "<tr>";
        echo        "<td height=21>"._TABLEDLGALIGN."</td>";
        echo        "<td>";
        echo                "<select name=alignment size=1>";
        echo                "<option value=\"\">"._TABLEDLGALIGNNOTSET."</option>";
        echo                "<option value=\"left\">"._TABLEDLGALIGNLEFT."</option>";
        echo                "<option value=\"right\">"._TABLEDLGALIGNRIGHT."</option>";
        echo                "<option value=\"textTop\">"._TABLEDLGALIGNTEXTTOP."</option>";
        echo                "<option value=\"absMiddle\">"._TABLEDLGALIGNAMIDDLE."</option>";
        echo                "<option value=\"baseline\">"._TABLEDLGALIGNBASELINE."</option>";
        echo                "<option value=\"absBottom\">"._TABLEDLGALIGNABOTTOM."</option>";
        echo                "<option value=\"bottom\">"._TABLEDLGALIGNBOTTOM."</option>";
        echo                "<option value=\"middle\">"._TABLEDLGALIGNMIDDLE."</option>";
        echo                "<option value=\"top\">"._TABLEDLGALIGNTOP."</option>";
        echo                "</select>";
        echo        "</td>";
        echo "</tr><tr>";
        echo         "<td><nobr>"._TABLEDLGBORDER."</nobr></td>";
        echo        "<td><input type=text name=border value=1 size=4 style='width: 100%'></td>";
        echo "</tr>";
        echo "</table>";
        echo "</fieldset>";
        echo "<fieldset style='width: 1%; text-align: center'>";
        echo "<legend>"._TABLEDLGSPACING."</legend>";
        echo "<table border=0 cellspacing=6 cellpadding=0>";
        echo "<tr>";
        echo        "<td><nobr>"._TABLEDLGCSPACING."</nobr></td>";
        echo        "<td><input type=text name=cellspacing value=1 style='width: 50px' maxlength=4></td>";
        echo "</tr><tr>";
        echo        "<td><nobr>"._TABLEDLGCPADDING."</nobr></td>";
        echo        "<td><input type=text name=cellpadding value=2 style='width: 50px' maxlength=4></td>";
        echo "</tr>";
        echo "</table>";
        echo "</fieldset>";
        echo "<div style='left: 307px; top: 8px; position: absolute'>";
        echo "<button style='width: 6em; height: 2.2em; margin: 0 0 3 0' type=submit onclick='btnOKClick()'>"._BTNENTER."</button><br>";
        echo "<button style='width: 6em; height: 2.2em; '                type=reset  onClick='window.close();'>"._BTNCANCEL."</button>";
        echo "</div>";
        echo "</body>";
        echo "</html>";
}

?>
